package com.xyhuo.leetcode.june;

public class FindMissingAndRepeatedValues {

    public static void main(String[] args) {
        FindMissingAndRepeatedValues f = new FindMissingAndRepeatedValues();
        int[][] grid = {{1, 3}, {2, 2}};
        f.findMissingAndRepeatedValues(grid);
    }

    public int[] findMissingAndRepeatedValues(int[][] grid) {
        int[] exists = new int[grid.length * grid.length];
        int[] ans = new int[2];
        for (int[] list : grid) {
            for (int item : list) {
                if (exists[item - 1] != 0) {
                    ans[0] = item;
                } else {
                    exists[item - 1] = 1;
                }
            }
        }
        for (int i = 0; i < exists.length; i++) {
            if (exists[i] == 0) {
                ans[1] = i + 1;
            }
        }
        return ans;
    }


}
